package com.evaluationSystem.config;

import com.alibaba.fastjson2.JSON;
import org.apache.shiro.web.filter.authc.UserFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;


public class ShiroUserFilter extends UserFilter {
    @Override
    protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException {
//        super.redirectToLogin(request, response);
        response.setContentType("application/json; charset=utf-8");
//返回json
        response.getWriter().write(JSON.toJSONString(R.failed(RCode.LOGIN_FAIL, "用户未登录，请先登录")));
    }
}
